/**
 * JAVACC DEMO 1.0
 * @copy right dwusoft company All rights reserved. 
 */
package com.apache.order.service.plugins;

import com.apache.api.manager.PluginConnector;
import com.apache.api.vo.ParamsVo;
import com.apache.api.vo.ResultEntity;
import com.apache.cache.util.Validator;
import com.apache.order.entity.TOrder;
import com.apache.order.manager.TOrderDetailManager;
import com.apache.order.manager.TOrderManager;
import com.apache.order.util.MessageUtil;

/**
 * description:  修改订单信息
 * @author Hou Dayu 创建时间：2015-8-10  
 */
public class EditOrderStatusPluginImpl implements PluginConnector {

	private TOrderManager tOrderManager;
	private TOrderDetailManager tOrderDetailManager;

	/**
	 * TODO 简单描述该方法的实现功能（可选）.  
	 * @see com.dwusoft.api.manager.PluginConnector#execute(com.dwusoft.api.vo.ParamsVo)  
	 */
	@Override
	public Object execute(ParamsVo vo) throws Exception {
		String orderId = String.valueOf(vo.getParams("orderId"));
		ResultEntity entity = new ResultEntity();
		entity.setResult("true");
		if (Validator.isNull(orderId)) {
			entity.setMessage(MessageUtil.getMessage("order-engine-0005", new String[0], "执行方法缺少必要参数"));
		}
		String orderStatus = String.valueOf(vo.getParams("orderStatus"));
		String payStatus = String.valueOf(vo.getParams("payStatus"));
		String dealPrice = String.valueOf(vo.getParams("dealPrice"));
		ParamsVo<TOrder> pvo = new ParamsVo<TOrder>();
		TOrder order = new TOrder();
		order.setOrderStatus(orderStatus);
		order.setPayStatus(payStatus);
		order.setDealPrice(dealPrice);
		pvo.setMethodKey("TOrderStatus");
		pvo.setObj(order);
		boolean mark = tOrderManager.editInfo(pvo);
		entity.setEntity(mark);
		if (mark) {
			entity.setMessage(MessageUtil.getMessage("order-engine-0013", new String[0], "订单操作成功"));
			OrderEnginePluginUtil.newFixed().saveLogMessage(vo);
		}
		return entity;
	}

	public void settOrderManager(TOrderManager tOrderManager) {
		this.tOrderManager = tOrderManager;
	}

	public void settOrderDetailManager(TOrderDetailManager tOrderDetailManager) {
		this.tOrderDetailManager = tOrderDetailManager;
	}

}
